package _spring_test;

import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.PropertyEditorRegistry;
import org.springframework.beans.propertyeditors.CustomDateEditor;

import java.beans.PropertyEditor;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: huangya
 * @Date: 2019/8/28
 * @Description:
 */
public class DatePropertyEditorRegister implements PropertyEditorRegistrar {
    @Override
    public void registerCustomEditors(PropertyEditorRegistry registry) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        PropertyEditor propertyEditor = new CustomDateEditor(sdf, true);
        registry.registerCustomEditor(Date.class, propertyEditor);
    }
}
